import { ref, Ref } from 'vue'
import useNotification from './useNotification'

export interface DarkModeInfo {
  darkMode: Ref<boolean>
  toggleDarkMode: () => void
}

const darkModeActive = ref(false)
const useDarkMode = () => {
  const { setNotification } = useNotification()

  const toggleDarkMode = () => {
    darkModeActive.value = !darkModeActive.value
    const type = darkModeActive.value ? 'dark mode' : 'light mode'
    return setNotification(`${type} turned on!`)
  }

  const darkData: DarkModeInfo = {
    darkMode: darkModeActive,
    toggleDarkMode
  }
  return darkData
}

export default useDarkMode
